package com.ruoyi.web.controller.api.register;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.model.RegisterBody;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.web.service.SysRegisterService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zzp
 * @version 1.0.0
 * @ClassName registerController.java
 * @Description 描述
 * @createTime 2022年10月24日 15:16:00
 */
@Api("小程序注册接口")
@RestController
@RequestMapping("/api/register")
public class RegisterController extends BaseController {

    @Autowired
    private SysRegisterService registerService;

    @ApiOperation("注册会员")
    @PostMapping("/user")
    public AjaxResult user(@RequestBody RegisterBody user) {
        String msg = registerService.registerWanCi(user);
        return StringUtils.isEmpty(msg) ? success() : error(msg);
    }

    @ApiOperation("注册加盟商")
    @PostMapping("/franchisee")
    public AjaxResult franchisee(@RequestBody RegisterBody user) {
        String msg = registerService.register(user);
        return StringUtils.isEmpty(msg) ? success() : error(msg);
    }
}